package com.ambow.core.dqUtil;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author Mryang
 * @since 2022.05.07
 * 工具:
 *   字符串判空
 */
public class StringUtil {
    public static String getFormatterDate(Date date, String yyyyMMddHHmmss) {
        return new SimpleDateFormat(yyyyMMddHHmmss).format(date);
    }

    public static String getStringFromInputStream(InputStream inputStream) {
        String string = "";
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"GB2312"));
            String buf = null;
            try {
                while((buf = bufferedReader.readLine()) != null){
                    string += buf;
                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }finally{
                try {
                    bufferedReader.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        } catch (Exception e) {
            // TODO: handle exception
        }
        return string;
    }
}